package com.wh.hotel.service.strategy.price;

import com.wh.hotel.po.PriceChangeVo;
import com.wh.hotel.util.PriceUtil;
import com.wh.hotel.vo.HotelPriceStrategyVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author luweije
 */
@Slf4j
@Component
public class PercentPriceCalculator extends PriceCalculatorAbstract {
    @Override
    public Integer calculateBasePrice(Integer basePrice, HotelPriceStrategyVo strategyVo) {
        PriceChangeVo priceChangeVo = strategyVo.getPriceChangeVo();
        int orgPrice = basePrice * (100 + priceChangeVo.getPriceGap()) / 100;
        orgPrice = PriceUtil.halfEven(orgPrice);
        return Math.max(orgPrice, PriceUtil.yuan2Cent(1));
    }
}
